from selenium.webdriver.common.by import By

from autoTest_ecshop.base_page.base import BasePage
from autoTest_ecshop.utils.log_util import logger

class LoginPage(BasePage):
    # 用户名定位器
    username_loc = (By.CSS_SELECTOR, '[name="username"]')

    # 错误用户名定位
    usernameErr_loc = (By.XPATH, '//div[@align="center"]/div/p[1]')

    # 密码定位器
    password_loc = (By.XPATH,'/html/body/div[7]/div[1]/form/table/tbody/tr[2]/td[2]/input')

    # 登录按钮定位器
    login_loc = (By.XPATH, '/html/body/div[7]/div[1]/form/table/tbody/tr[4]/td[2]/input[3]')

    # 登录后的验证信息定位器
    homePage_loc = (By.CSS_SELECTOR,'[id="ECS_MEMBERZONE"]>font')

    def loginSysytem(self,username,password):
        logger.info("输入用户名")
        # 输入用户名
        self.input_data(self.username_loc,username)
        logger.info("输入密码")
        # 输入密码
        self.input_data(self.password_loc,password)
        logger.info("点击登录")
        # 点击登录按钮
        self.btn(self.login_loc)

class ShopPage(BasePage):
    # 查看购物车定位
    shop_doc = (By.XPATH,'//*[@id="topNav"]/a[1]')

    # # 搜索框定位
    # seek_loc = (By.XPATH,'//*[@id="keyword"]')
    #
    # # 搜索点击按钮定位
    # seek_btn_loc = (By.XPATH,'//*[@id="searchForm"]/input[2]')
    #
    # # 购买定位
    # buy_loc = (By.XPATH,'//*[@id="compareForm"]/div/div/div/a[3]')
    #
    # # 结算中心定位
    # buy_center_loc = (By.XPATH,'/html/body/div[7]/div[1]/table/tbody/tr/td[2]/a/img')
    #
    # # 提交订单定位
    # submit_loc = (By.XPATH,'//*[@id="theForm"]/div[15]/div[2]/input[1]')

# # 实例化页面对象
# loginPage = LoginPage(driver)

